<template>
	<view class="">
		<view class="" v-if="list1.length>0">
			<view class=" w100 pt-30 pb-40 ">
				<view class="mlr-36 flex">
					<view class="">
						<view class="size-36">
							停车位值（停车中）
						</view>
						<view class="mt-20 gray-1">
							西湖区河坊街地下停车场C区36号位 <text class="ml-20 blue-1">360M</text>
						</view>
						<view class="mt-20 gray-1">
							停车时长:<text class="ml-20 blue-1 ">03：20：00</text>
						</view>
					</view>
					<view class="mt-30 ml-20 center">
						<image style="width: 250rpx; height: 200rpx; border-radius: 16rpx; "
							src="../../static/my-bg.png" mode="">
						</image>
					</view>
				</view>
			</view>
			<view class="mlr-36">
				<view class="border-sty" @click="dj_submit()" @change="change">
					<text class="text1">呼叫取车</text>
				</view>
			</view>
		</view>
		<view class=" size-36 mt-100" v-if="!list1.length>0">
			<view class="mlr-36">
				<view class="border-sty" @change="change">
					<text class="text1">暂无取车订单！</text>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	import amapFile from '../../libs/amap-wx.js'
	import longDate from '../long-date/long-date.vue'
	export default {
		components: {
			longDate
		},
		//代人叫车
		props: ["other", "showTime", "location", "ids1"],
		data() {
			return {
				list1: [],
				list: [],
				drive_type: '泊车订单',
				ids2: '',
				time: '预约时间',
				key: '9598a5f0f1df135f2b370942d9656f73',
				weather: '晴',
				temperature: '20',
				tabs: '',
			}
		},
		onLoad() {
			this.getList();

		},
		watch: {
			ids1(news, olds) { //监听props ids1值 
				this.ids2 = news; // console.log('取车99', news, olds);
			}
		},
		computed: {
			...mapState(['city', "start", "end"]),
		},
		mounted() {
			// console.log(this.city);
			this.myAmapFun = new amapFile.AMapWX({
				key: this.key
			});
			// this.getWeather();
			this.init();
		},
		methods: {
			init() {

				this.$http('/addons/ddrive/order/index', {
					drive_type: "泊车订单",
					status: '99',
					page: 1,
				}, "POST").then(data => {
					// if (data.data.length < 10) {
					// 	this.status = "nomore"
					// } else {
					// 	this.page = this.page + 1
					// 	this.status = "loadmore"
					// }
					this.list1 = this.list.concat(data.data)
					console.log("泊车订单", data.data);
				})
			},
			change(index) {
				this.index = index;
				this.current = this.tabList[index].id;
				if (this.current) {
					uni.$emit('price')
				}
				// if (this.current == 2) {
				// 	uni.$emit('price')
				// }
			},
			//获取天气
			getWeather() {
				let _this = this
				this.myAmapFun.getWeather({
					city: this.city,
					success: (data) => {
						console.log("获取城市，天气信息", data);
						_this.weather = data.liveData.weather
						_this.temperature = data.liveData.temperature
					},
					fail: (msg) => {
						uni.showToast({
							title: '没有开启位置权限',
							icon: 'none'
						})
					}
				});
			},
			getCity() {
				uni.navigateTo({
					url: '/pages/home/city'
				})
			},
			// 选时间
			getTime() {
				this.$emit('showTime')
			},
			daiti() {
				uni.navigateTo({
					url: '/pages/home/dj-other'
				})
			},
			// 确定时间
			onSelectTime(res) {
				console.log("预约时间", res);
				uni.showToast({
					title: '时间已选，点击呼叫',
					icon: 'none'
				})
				if (res.tip) {
					uni.showToast({
						title: res.tip,
						icon: 'none'
					})
				} else {
					this.time = res.time
					this.$emit('close');
				}
			},
			// 预约时间
			confirmTime(time) {
				console.log("预约时间1", time);
			},
			getAddress(type) {
				uni.navigateTo({
					url: '/pages/home/search?type=' + type + '&location=' + this.location
				})
			},

			// 实时订单检测
			getList() {
				this.$http('/addons/ddrive/order/order_taking', {}, "POST").then(data => {
					this.list = data.data.length
					this.hylist = data.hy
				})
			},
			dj_submit() {
				this.getList();
				if (!Object.keys(this.end).length == 0) {
					uni.showToast({
						title: '请选择目的地',
						icon: 'none'
					})
				} else if (this.list >= 1) {
					uni.showToast({
						icon: 'none',
						title: '有进行中or未支付订单'
					})
				} else {
					let query = {
						ids2: this.ids2, //tabs
						time: this.time, //约约时间
						other: this.other, //代叫人信息
						address: this.start.address + this.start.name,
					}
					console.log("呼叫-传入信息", query);
					uni.navigateTo({
						url: '/pages/home/bc-call/bc-callBcy?query=' + encodeURIComponent(JSON.stringify(query))
					})
					// uni.navigateTo({
					// 	url: '/pages/home/dj-confirm?query=' + encodeURIComponent(JSON.stringify(query))
					// })
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	/deep/.u-primary-hover {
		background: linear-gradient(to right, #00b6b4, #00d496) !important;
	}

	page {
		background-color: #ffffff;
	}

	.border-sty {
		width: 100%;
		height: 88rpx;
		border-radius: 50px;
		background-color: #3CBCA3;
		display: flex;
		align-items: center;
		justify-content: center;

		.text1 {
			font-size: 32rpx;
			color: #ffff;
		}
	}

	.img-car {
		image {
			width: 226rpx;
			height: 98rpx;
		}
	}

	.img-point {
		image {
			width: 24rpx;
			height: 24rpx;
		}
	}
</style>
